package com.brainsitter;

import com.brainsitter.db.DBHandler;
import com.brainsitter.db.tables.Profile;

import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView;

public class CredentialTabActivity extends Activity{
	
	TextView name;
	TextView earnedpoints;
	TextView totaltasks;
	TextView totaltaskscompleted;
	TextView totaltasksfailed;
	DBHandler db;

	/** Called when the activity is first created. */
	@Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.credential_tab);
        initialize();
        feed();
        
	}
	
	public void initialize() {
		db = new DBHandler(this);
		name = (TextView) findViewById(R.id.name);
		earnedpoints = (TextView) findViewById(R.id.earnedpoints);
		totaltasks = (TextView) findViewById(R.id.totaltasks);
		totaltaskscompleted = (TextView) findViewById(R.id.totaltaskscompleted);
		totaltasksfailed = (TextView) findViewById(R.id.totaltasksfailed);
	}
	
	public void feed() {
		Profile user = db.getProfile();
		name.setText(user.getName());
		earnedpoints.setText(String.valueOf(db.getPoints()));
		totaltasks.setText(String.valueOf(db.getTaskCount()));
		totaltaskscompleted.setText(String.valueOf(db.getCompletedTaskCount()));
		totaltasksfailed.setText(String.valueOf(db.getFailedTaskCount()));
	}

	public void onResume(){
		super.onResume();
		feed();
	}
}
